package main

import (
	"awesomeProject/controller"
	"github.com/gin-gonic/gin"
	_ "github.com/lib/pq"
	"log"
)

func initRouter(r *gin.Engine) {
	apiRouter := r.Group("/slimarveous")
	apiRouter.POST("/login", controller.Login)
	apiRouter.POST("/register", controller.Register)
	apiRouter.POST("/set_profile", controller.SetProfile)
	apiRouter.POST("/get_profile", controller.GetProfile)
	apiRouter.POST("/search_friend", controller.SearchFriend)
	apiRouter.POST("/add_friend", controller.AddFriend)
	apiRouter.POST("/get_friend_list", controller.GetFriendList)
	apiRouter.POST("/get_history", controller.GetHistory)
	apiRouter.POST("/delete_friend", controller.DeleteFriend)

	apiRouter.GET("/ws", controller.WsHandler)
}

func main() {
	r := gin.Default()
	err := controller.InitAuth()
	if err != nil {
		log.Fatal(err)
	}
	initRouter(r)
	err = r.Run("0.0.0.0:19999")
	if err != nil {
		return
	}
}
